package com.ruandi.homework;

import java.util.Scanner;

class Worker{
    private String name;
    private int year;

    public Worker() {
    }

    public Worker(String name, int year) {
        this.name = name;
        this.year = year;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getYear() {
        return year;
    }

    public void setYear(int year) {
        this.year = year;
    }
}
public class Test1 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.println("请输入工人姓名：");
        String name = input.nextLine();
        System.out.println("请输入工人工龄：");
        int year = input.nextInt();
        Worker worker = new Worker();
        worker.setName(name);
        worker.setYear(year);
        System.out.println("该工人对象的信息如下：");
        System.out.println("姓名："+worker.getName());
        System.out.println("工龄："+worker.getYear());
    }
}
